
package au.com.lastweekend.jim.actions;

import au.com.lastweekend.jim.controller.SelectedImagesController;
import au.com.lastweekend.jim.imagebase.ImageManager;
import au.com.lastweekend.jim.model.ContactSheetImageItem;

public class RotateAction extends AbstractImageAction {

    public interface RotateActionController extends SelectedImagesController {

        boolean isRotateByTag();

    }

    public enum Rotation {
        CLOCKWISE("Rotate right", "arrow_rotate_clockwise.png", "Rotate image clockwise", ImageManager.Rotation.CLOCKWISE),
        ANTI_CLOCKWISE("Rotate left", "arrow_rotate_anticlockwise.png", "Rotate image anti-clockwise",
                ImageManager.Rotation.ANTI_CLOCKWISE);

        private String name;
        private String iconPath;
        private String longDesc;
        private ImageManager.Rotation imageManagerDirection;

        Rotation(String name, String iconPath, String longDesc, ImageManager.Rotation direction) {

            this.name = name;
            this.iconPath = iconPath;
            this.longDesc = longDesc;
            this.imageManagerDirection = direction;
        }
    }

    private static final long serialVersionUID = 1L;
    private Rotation direction;

    public RotateAction(RotateActionController controller, Rotation direction) {

        super(controller, direction.name, direction.iconPath, direction.name, direction.longDesc, "Image");
        this.direction = direction;
        this.controller = controller;
    }
    private RotateActionController controller;

    @Override
    protected void performImageOperation(ContactSheetImageItem imageItem) {

        controller.getImageManager().rotate(imageItem.getImageInfo(), direction.imageManagerDirection, controller.isRotateByTag());

    }

    @Override
    protected void postWorkDone() {

    }

}
